package com.yokit.c2c.service;

import com.yokit.c2c.mapper.GoodsMapper;
import com.yokit.c2c.pojo.Goods;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author fengzeng
 * @create 2021/6/13 21:24
 */
@Service
public class GoodsService {
  @Resource
  private GoodsMapper goodsMapper;

  public Goods selectByGoodsId(Integer goodsId) {
     return goodsMapper.selectByPrimaryKey(Integer.valueOf(goodsId));
  }

  public List<Goods> select5HotGoods() {
    return goodsMapper.select5HotGoods();
  }

  public void createGoods(Goods goods) {
    goodsMapper.insertSelective(goods);
  }

  public List<Goods> selectAll() {
    return goodsMapper.selectAll();
  }

  public List<Goods> selectByCatId(Integer catId) {
    return goodsMapper.selectByCatId(catId);
  }

  public List<Goods> selectByGoodsName(String goodsName) {
    return goodsMapper.selectByGoodsName(goodsName);
  }

  public List<Goods> selectByShopId(Integer shopId) {
    return goodsMapper.selectByShopId(shopId);
  }

  public void updateGoods(Goods goods) {
    goodsMapper.updateByPrimaryKeySelective(goods);
  }

  public void deleteGoodsById(Integer goodsIdInt) {
    goodsMapper.deleteByPrimaryKey(goodsIdInt);
  }
}
